import tornado.web
import tornado.ioloop
from manage_activity import ManageActivity


class IndexHandler(tornado.web.RequestHandler):
    manage_activity = ManageActivity()

    def get(self):
        _id = int(self.get_query_argument('id', '10000'))
        _time = self.get_query_argument('time', '20180703000000')
        result = {
            'result': self.manage_activity.get_activity(_id).is_open(_time)
        }
        self.write(result)


if __name__ == '__main__':
    app = tornado.web.Application([
        (r"/", IndexHandler),
    ])
    app.listen(8000)
    tornado.ioloop.IOLoop.current().start()
